<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
</head>
<body>

</body>
<script type="text/javascript" src="../script/api.js" ></script>
<script type="text/javascript">
    apiready = function(){

      api.showProgress({
          title: '努力加载中...',
          text: '客官请骚等',
          modal: false
      });
      toLive();



    }

		function toLive(){

      var obj = api.require('aliyunLive');
      obj.init({
         rect: {
               x: 0,
               y: 100,
               w: api.winWidth,
               h: api.winHeight
          },
          accessKeyId : 'LTAI36cx4lfjyzCS',
          accessKeySecret : 'R9gueXV9kcym1tyxYzvYHLmLAAshfz',
          businessId : 'video_live'
      }, function(ret, err) {
          if(ret){
              obj.prepareToPlay({
                  url:api.pageParam.url
              }, function(ret, err) {
                  if(ret && ret.status){

                    obj.addEventListener(function(ret){
                        if (ret.eventName == 'error') {
                          alert('翻车了~换个房间试试');
                          api.closeWin();
                          api.hideProgress();
                        }
                        else {
                          obj.play();
                          api.hideProgress();
                        }
                    });
                  }else {
                    alert('翻车了~换个房间试试');
                    api.closeWin();
                    api.hideProgress();
                  }
              });
          }else {
            alert('翻车了~换个房间试试');
            api.closeWin();
            api.hideProgress();
          }
      });

    }



</script>
</html>
